//
//  SecondViewController.swift
//  Demo
//
//  Created by wyatt on 15/3/9.
//  Copyright (c) 2015年 Wanqing Wang. All rights reserved.
//

import UIKit

// 1
protocol SecondViewControllerDelegate: class {
    func changeLabelContent(controller: SecondViewController, content str: String)
}

class SecondViewController: UIViewController {
    
    // 2
    
    weak var delegate: SecondViewControllerDelegate?
    @IBOutlet weak var textField: UITextField!
    
    override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    
    // 3
    @IBAction func didClick() {
        var text = textField.text
        delegate?.changeLabelContent(self, content: text)
    }
}
